package com.buddies.lottery.ui.withdraw.record;

import android.widget.TextView;

import com.buddies.lottery.R;
import com.buddies.lottery.data.bean.WithdrawRecord;
import com.buddies.lottery.utils.DateUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

public class WithdrawRecordAdapter extends BaseQuickAdapter<WithdrawRecord, BaseViewHolder> {

    public WithdrawRecordAdapter(List<WithdrawRecord> data) {
        super(R.layout.item_pay_record, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, WithdrawRecord item) {
        helper.setText(R.id.tv_result, item.status);
        helper.setText(R.id.tv_time, DateUtils.format(item.create_at * 1000));

        TextView tvMoney = helper.getView(R.id.tv_money);
        if (item.money > 0) {
            tvMoney.setText(String.format("+ %s", item.money));
        } else {
            tvMoney.setText(String.format("- %s", Math.abs(item.money)));
        }
        tvMoney.setSelected(item.money < 0);
    }

}
